from day01.basecla import BaseClass
from day01.basecla import driver
from selenium.webdriver.common.by import By
from time import sleep
#导入select类
from selenium.webdriver.support.select import Select
c=BaseClass()
c.open_browser('file:///E:/%E8%93%AC%E8%8E%B1%E5%B0%8F%E8%AF%BE2024%E6%B5%8B%E8%AF%95/%E7%AC%AC%E5%9B%9B%E9%98%B6%E6%AE%B5/Selenium%E8%87%AA%E5%8A%A8%E5%8C%96/selenium_demo/day05demo/demo01.html')
mycity=c.location(By.XPATH,"//*[@id='city']")
mynation=c.location(By.XPATH,'//*[@name="nation"]')
mycity1=Select(mycity)
mycity1.select_by_index(3)
sleep(2)
mycity1.select_by_value('天津')
sleep(2)
mycity1.select_by_visible_text('上海')
sleep(2)
#对民族进行定位
mynation1=Select(mynation)
mynation1.select_by_index(3)
if mynation1.is_multiple:
    print('我被多选了，被多选项为:')
else:
    print('我没有被多选')
nationlist=[]
for i in mynation1.all_selected_options:
    nationlist.append(i.text)
    print(nationlist)
    print(i.text)
